from typing import Optional

from model.uml_element import UmlElement
from model.uml_value import UmlValue
from model.uml_xmi_info import UmlXmiInfo


class UmlExtensionEnd(UmlElement):
    def __init__(self) -> None:
        super().__init__(UmlXmiInfo.type_extension_end)
        self.name: str = ""
        self.type: str = ""
        self.aggregation: str = ""
        self.association: str = ""
        self.lowerValue: Optional[UmlValue] = None

    def to_json(self) -> dict[str, object]:
        json: dict = super().to_json()
        json["name"] = self.name
        json["type"] = self.type
        json["aggregation"] = self.aggregation
        json["association"] = self.association

        if self.lowerValue is not None:
            json["lowerValue"] = self.lowerValue.to_json()

        return json
